﻿namespace HRM.CORE.Process
{
    using DevExpress.Utils;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using APP.HELPER;
    using Common.Class; using APP.HELPER.Utils.Language; using Security.Security; using Dictionary.ERP;
    using HRM.CORE;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms; using Common;
    using Common;
    using Dictionary.ERP;
    using Extra.ERP;
    using Security.ERP;

    public class xucConfirmTimeKeeperAdd : Common.xucBaseAddH
    {
        private ComboBoxEdit cboStatus;
        private GridColumn colEmployeeCode;
        private GridColumn colFirstName;
        private GridColumn colLastName;
        private GridColumn colShiftCode;
        private GridColumn colShiftName;
        private IContainer components = null;
        private DateEdit dtDate;
        private DateEdit dtWriteDate;
        private GridLookUpEdit glkEmployeeCode;
        private GridLookUpEdit glkShift;
        private GridView gridLookUpEdit1View;
        private GridView gridView1;
        private GroupBox groupBox2;
        private GroupControl groupControl1;
        private LabelControl labelControl1;
        private LabelControl labelControl10;
        private LabelControl labelControl11;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private LabelControl labelControl5;
        private LabelControl labelControl7;
        private LabelControl labelControl8;
        private LabelControl labelControl9;
        private LabelControl lbReasonCannot;
        private Guid m_ConfirmTimeKeeperID = Guid.Empty;
        private string m_EmployeeCode = "";
        private TimeEdit teTimeIn;
        private TimeEdit teTimeOut;
        private MemoEdit txtDescription;
        private TextEdit txtEmployeeName;
        private MemoEdit txtReason;
        private TextEdit txtReasonCannot;

        public event SuccessEventHander Success;

        public xucConfirmTimeKeeperAdd()
        {
            this.InitializeComponent();
            this.InitComponent();
            this.InitData();
        }

        protected override void Add()
        {
            base.Add();
            this.dtWriteDate.DateTime = System.DateTime.Now;
            this.dtDate.DateTime = System.DateTime.Now;
            this.teTimeIn.Time = System.DateTime.Now;
            this.teTimeOut.Time = System.DateTime.Now;
            this.glkShift.EditValue = null;
        }

        private void cboStatus_EditValueChanged(object sender, EventArgs e)
        {
            if (this.cboStatus.SelectedIndex == 2)
            {
                this.lbReasonCannot.Visible = true;
                this.txtReasonCannot.Visible = true;
            }
            else
            {
                this.lbReasonCannot.Visible = false;
                this.txtReasonCannot.Visible = false;
            }
        }

        public void Clear()
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void glkEmployeeCode_EditValueChanged(object sender, EventArgs e)
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.glkEmployeeCode.EditValue.ToString());
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
            this.m_EmployeeCode = this.glkEmployeeCode.EditValue.ToString();
            this.LoadEmployeeInformation();
        }

        protected override void Init()
        {
            base.Init();
        }

        private HRM_PROCESS_CONFIRMTIMEKEEPER InitClass()
        {
            return new HRM_PROCESS_CONFIRMTIMEKEEPER { ConfirmTimeKeeperID = this.m_ConfirmTimeKeeperID, EmployeeCode = this.glkEmployeeCode.EditValue.ToString(), WriteDate = this.dtWriteDate.DateTime, Date = this.dtDate.DateTime, TimeIn = this.teTimeIn.Time, TimeOut = this.teTimeOut.Time, ShiftCode = this.glkShift.EditValue.ToString(), Reason = this.txtReason.Text, Status = this.cboStatus.SelectedIndex, ReasonCannot = this.txtReasonCannot.Text, Description = this.txtDescription.Text };
        }

        private void InitComponent()
        {
            this.dtWriteDate.DateTime = System.DateTime.Now;
            this.dtDate.DateTime = System.DateTime.Now;
            this.teTimeIn.Time = System.DateTime.Now;
            this.teTimeOut.Time = System.DateTime.Now;
        }

        private void InitData()
        {
            new HRM_EMPLOYEE().AddGridLookupEdit(this.glkEmployeeCode);
            new DIC_SHIFT().AddGridLookupEdit(this.glkShift);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(xucConfirmTimeKeeperAdd));
            this.txtReason = new MemoEdit();
            this.txtDescription = new MemoEdit();
            this.labelControl1 = new LabelControl();
            this.labelControl2 = new LabelControl();
            this.labelControl3 = new LabelControl();
            this.labelControl7 = new LabelControl();
            this.glkEmployeeCode = new GridLookUpEdit();
            this.gridLookUpEdit1View = new GridView();
            this.colEmployeeCode = new GridColumn();
            this.colFirstName = new GridColumn();
            this.colLastName = new GridColumn();
            this.txtEmployeeName = new TextEdit();
            this.labelControl8 = new LabelControl();
            this.labelControl9 = new LabelControl();
            this.dtWriteDate = new DateEdit();
            this.labelControl10 = new LabelControl();
            this.groupBox2 = new GroupBox();
            this.teTimeIn = new TimeEdit();
            this.teTimeOut = new TimeEdit();
            this.groupControl1 = new GroupControl();
            this.glkShift = new GridLookUpEdit();
            this.gridView1 = new GridView();
            this.colShiftCode = new GridColumn();
            this.colShiftName = new GridColumn();
            this.labelControl5 = new LabelControl();
            this.lbReasonCannot = new LabelControl();
            this.dtDate = new DateEdit();
            this.labelControl11 = new LabelControl();
            this.cboStatus = new ComboBoxEdit();
            this.txtReasonCannot = new TextEdit();
            ((ISupportInitialize) base.Err).BeginInit();
            base.imageCollection2.BeginInit();
            this.txtReason.Properties.BeginInit();
            this.txtDescription.Properties.BeginInit();
            this.glkEmployeeCode.Properties.BeginInit();
            this.gridLookUpEdit1View.BeginInit();
            this.txtEmployeeName.Properties.BeginInit();
            this.dtWriteDate.Properties.VistaTimeProperties.BeginInit();
            this.dtWriteDate.Properties.BeginInit();
            this.groupBox2.SuspendLayout();
            this.teTimeIn.Properties.BeginInit();
            this.teTimeOut.Properties.BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.glkShift.Properties.BeginInit();
            this.gridView1.BeginInit();
            this.dtDate.Properties.VistaTimeProperties.BeginInit();
            this.dtDate.Properties.BeginInit();
            this.cboStatus.Properties.BeginInit();
            this.txtReasonCannot.Properties.BeginInit();
            base.SuspendLayout();
            base.btnSave.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnSave.Location = new Point(0xf2, 320);
            base.btnSave.TabIndex = 0x13;
            base.btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnCancel.Location = new Point(0x1bf, 320);
            base.btnCancel.TabIndex = 0x15;
            base.btnSaveNew.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            base.btnSaveNew.Location = new Point(0x157, 320);
            base.btnSaveNew.TabIndex = 20;
            base.imageCollection2.ImageStream = (ImageCollectionStreamer) manager.GetObject("imageCollection2.ImageStream");
            this.txtReason.Location = new Point(80, 0x3e);
            this.txtReason.Name = "txtReason";
            this.txtReason.Size = new Size(0x1ce, 0x33);
            this.txtReason.TabIndex = 6;
            this.txtDescription.Location = new Point(80, 0x102);
            this.txtDescription.Name = "txtDescription";
            this.txtDescription.Size = new Size(0x1ce, 0x2c);
            this.txtDescription.TabIndex = 0x12;
            this.labelControl1.AllowHtmlString = true;
            this.labelControl1.Appearance.Options.UseTextOptions = true;
            this.labelControl1.Appearance.TextOptions.WordWrap = WordWrap.Wrap;
            this.labelControl1.AutoSizeMode = LabelAutoSizeMode.None;
            this.labelControl1.Location = new Point(8, 0x40);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(60, 0x26);
            this.labelControl1.TabIndex = 5;
            this.labelControl1.Text = "L\x00fd do x\x00e1c nhận:";
            this.labelControl2.AllowHtmlString = true;
            this.labelControl2.Location = new Point(0x17, 0x21);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(40, 14);
            this.labelControl2.TabIndex = 7;
            this.labelControl2.Text = "Giờ v\x00e0o:";
            this.labelControl3.AllowHtmlString = true;
            this.labelControl3.Location = new Point(0xaf, 0x21);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x20, 14);
            this.labelControl3.TabIndex = 9;
            this.labelControl3.Text = "Giờ ra:";
            this.labelControl7.AllowHtmlString = true;
            this.labelControl7.Location = new Point(11, 0x105);
            this.labelControl7.Name = "labelControl7";
            this.labelControl7.Size = new Size(0x40, 14);
            this.labelControl7.TabIndex = 0x11;
            this.labelControl7.Text = "Ghi ch\x00fa kh\x00e1c:";
            this.glkEmployeeCode.Location = new Point(80, 30);
            this.glkEmployeeCode.Name = "glkEmployeeCode";
            this.glkEmployeeCode.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkEmployeeCode.Properties.NullText = "[Chọn M\x00e3 NV]";
            this.glkEmployeeCode.Properties.View = this.gridLookUpEdit1View;
            this.glkEmployeeCode.Size = new Size(100, 20);
            this.glkEmployeeCode.TabIndex = 1;
            this.glkEmployeeCode.EditValueChanged += new EventHandler(this.glkEmployeeCode_EditValueChanged);
            this.gridLookUpEdit1View.Columns.AddRange(new GridColumn[] { this.colEmployeeCode, this.colFirstName, this.colLastName });
            this.gridLookUpEdit1View.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridLookUpEdit1View.Name = "gridLookUpEdit1View";
            this.gridLookUpEdit1View.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridLookUpEdit1View.OptionsView.ShowAutoFilterRow = true;
            this.gridLookUpEdit1View.OptionsView.ShowGroupPanel = false;
            this.colEmployeeCode.Caption = "M\x00e3 nh\x00e2n vi\x00ean";
            this.colEmployeeCode.FieldName = "EmployeeCode";
            this.colEmployeeCode.Name = "colEmployeeCode";
            this.colEmployeeCode.Visible = true;
            this.colEmployeeCode.VisibleIndex = 0;
            this.colFirstName.Caption = "Họ l\x00f3t";
            this.colFirstName.FieldName = "FirstName";
            this.colFirstName.Name = "colFirstName";
            this.colFirstName.Visible = true;
            this.colFirstName.VisibleIndex = 1;
            this.colLastName.Caption = "T\x00ean";
            this.colLastName.FieldName = "LastName";
            this.colLastName.Name = "colLastName";
            this.colLastName.Visible = true;
            this.colLastName.VisibleIndex = 2;
            this.txtEmployeeName.Location = new Point(0xba, 30);
            this.txtEmployeeName.Name = "txtEmployeeName";
            this.txtEmployeeName.Properties.ReadOnly = true;
            this.txtEmployeeName.Size = new Size(0x99, 20);
            this.txtEmployeeName.TabIndex = 2;
            this.labelControl8.AllowHtmlString = true;
            this.labelControl8.Location = new Point(8, 0x1f);
            this.labelControl8.Name = "labelControl8";
            this.labelControl8.Size = new Size(0x3e, 14);
            this.labelControl8.TabIndex = 0;
            this.labelControl8.Text = "Chọn NV <color=red>(*)</color>:";
            this.labelControl9.AllowHtmlString = true;
            this.labelControl9.Location = new Point(0x161, 0x21);
            this.labelControl9.Name = "labelControl9";
            this.labelControl9.Size = new Size(0x47, 14);
            this.labelControl9.TabIndex = 3;
            this.labelControl9.Text = "Ng\x00e0y viết đơn:";
            this.dtWriteDate.EditValue = null;
            this.dtWriteDate.Location = new Point(430, 30);
            this.dtWriteDate.Name = "dtWriteDate";
            this.dtWriteDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtWriteDate.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.dtWriteDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtWriteDate.Size = new Size(0x70, 20);
            this.dtWriteDate.TabIndex = 4;
            this.dtWriteDate.TabStop = false;
            this.labelControl10.AllowHtmlString = true;
            this.labelControl10.Location = new Point(0x14d, 0x7e);
            this.labelControl10.Name = "labelControl10";
            this.labelControl10.Size = new Size(0x5f, 14);
            this.labelControl10.TabIndex = 0x16;
            this.labelControl10.Text = "Ca (buổi) x\x00e1c nhận:";
            this.groupBox2.Controls.Add(this.labelControl3);
            this.groupBox2.Controls.Add(this.labelControl2);
            this.groupBox2.Controls.Add(this.teTimeIn);
            this.groupBox2.Controls.Add(this.teTimeOut);
            this.groupBox2.Location = new Point(11, 0x93);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new Size(0x213, 70);
            this.groupBox2.TabIndex = 0x19;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Thời gian x\x00e1c nhận";
            this.teTimeIn.EditValue = null;
            this.teTimeIn.Location = new Point(0x45, 30);
            this.teTimeIn.Name = "teTimeIn";
            this.teTimeIn.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teTimeIn.Properties.DisplayFormat.FormatString = "HH:ss tt";
            this.teTimeIn.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.teTimeIn.Properties.EditFormat.FormatString = "HH:ss tt";
            this.teTimeIn.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.teTimeIn.Properties.EditValueChangedFiringMode = EditValueChangedFiringMode.Default;
            this.teTimeIn.Properties.Mask.EditMask = "HH:ss tt";
            this.teTimeIn.Size = new Size(0x59, 20);
            this.teTimeIn.TabIndex = 8;
            this.teTimeIn.TabStop = false;
            this.teTimeOut.EditValue = null;
            this.teTimeOut.Location = new Point(0xd5, 30);
            this.teTimeOut.Name = "teTimeOut";
            this.teTimeOut.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.teTimeOut.Properties.DisplayFormat.FormatString = "HH:ss tt";
            this.teTimeOut.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.teTimeOut.Properties.EditFormat.FormatString = "HH:ss tt";
            this.teTimeOut.Properties.EditFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            this.teTimeOut.Properties.EditValueChangedFiringMode = EditValueChangedFiringMode.Default;
            this.teTimeOut.Properties.Mask.EditMask = "HH:ss tt";
            this.teTimeOut.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.teTimeOut.Size = new Size(100, 20);
            this.teTimeOut.TabIndex = 10;
            this.teTimeOut.TabStop = false;
            this.groupControl1.Controls.Add(this.glkShift);
            this.groupControl1.Controls.Add(this.labelControl5);
            this.groupControl1.Controls.Add(this.lbReasonCannot);
            this.groupControl1.Controls.Add(this.dtDate);
            this.groupControl1.Controls.Add(this.labelControl11);
            this.groupControl1.Controls.Add(this.cboStatus);
            this.groupControl1.Controls.Add(this.txtReasonCannot);
            this.groupControl1.Controls.Add(this.groupBox2);
            this.groupControl1.Controls.Add(this.labelControl10);
            this.groupControl1.Controls.Add(this.labelControl9);
            this.groupControl1.Controls.Add(this.dtWriteDate);
            this.groupControl1.Controls.Add(this.labelControl8);
            this.groupControl1.Controls.Add(this.txtReason);
            this.groupControl1.Controls.Add(this.txtEmployeeName);
            this.groupControl1.Controls.Add(this.txtDescription);
            this.groupControl1.Controls.Add(this.glkEmployeeCode);
            this.groupControl1.Controls.Add(this.labelControl1);
            this.groupControl1.Controls.Add(this.labelControl7);
            this.groupControl1.Dock = DockStyle.Top;
            this.groupControl1.Location = new Point(0, 0);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0x229, 0x137);
            this.groupControl1.TabIndex = 0x1a;
            this.groupControl1.Text = "Th\x00f4ng Tin X\x00e1c Nhận Giờ C\x00f4ng";
            this.glkShift.EditValue = "";
            this.glkShift.Location = new Point(0x1b2, 0x7c);
            this.glkShift.Name = "glkShift";
            this.glkShift.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.glkShift.Properties.NullText = "[Chọn ca x\x00e1c nhận]";
            this.glkShift.Properties.View = this.gridView1;
            this.glkShift.Size = new Size(0x6c, 20);
            this.glkShift.TabIndex = 0x21;
            this.gridView1.Columns.AddRange(new GridColumn[] { this.colShiftCode, this.colShiftName });
            this.gridView1.FocusRectStyle = DrawFocusRectStyle.RowFocus;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.colShiftCode.Caption = "M\x00e3 ca";
            this.colShiftCode.FieldName = "ShiftCode";
            this.colShiftCode.Name = "colShiftCode";
            this.colShiftCode.Visible = true;
            this.colShiftCode.VisibleIndex = 0;
            this.colShiftName.Caption = "T\x00ean ca";
            this.colShiftName.FieldName = "ShiftName";
            this.colShiftName.Name = "colShiftName";
            this.colShiftName.Visible = true;
            this.colShiftName.VisibleIndex = 1;
            this.labelControl5.AllowHtmlString = true;
            this.labelControl5.Location = new Point(0x8a, 0x7d);
            this.labelControl5.Name = "labelControl5";
            this.labelControl5.Size = new Size(0x4c, 14);
            this.labelControl5.TabIndex = 11;
            this.labelControl5.Text = "Ng\x00e0y x\x00e1c nhận:";
            this.lbReasonCannot.Location = new Point(0xc4, 0xe8);
            this.lbReasonCannot.Name = "lbReasonCannot";
            this.lbReasonCannot.Size = new Size(30, 13);
            this.lbReasonCannot.TabIndex = 0x20;
            this.lbReasonCannot.Text = "L\x00fd do:";
            this.lbReasonCannot.Visible = false;
            this.dtDate.EditValue = null;
            this.dtDate.Location = new Point(220, 0x7c);
            this.dtDate.Name = "dtDate";
            this.dtDate.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.dtDate.Properties.Mask.UseMaskAsDisplayFormat = true;
            this.dtDate.Properties.VistaTimeProperties.Buttons.AddRange(new EditorButton[] { new EditorButton() });
            this.dtDate.Size = new Size(100, 20);
            this.dtDate.TabIndex = 12;
            this.dtDate.TabStop = false;
            this.labelControl11.AllowHtmlString = true;
            this.labelControl11.Location = new Point(11, 230);
            this.labelControl11.Name = "labelControl11";
            this.labelControl11.Size = new Size(0x35, 14);
            this.labelControl11.TabIndex = 0x1f;
            this.labelControl11.Text = "Trạng th\x00e1i:";
            this.cboStatus.EditValue = "Chờ duyệt";
            this.cboStatus.Location = new Point(80, 0xe4);
            this.cboStatus.Name = "cboStatus";
            this.cboStatus.Properties.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.cboStatus.Properties.Items.AddRange(new object[] { "Chờ duyệt", "Đ\x00e3 duyệt", "Kh\x00f4ng được duyệt" });
            this.cboStatus.Size = new Size(110, 20);
            this.cboStatus.TabIndex = 30;
            this.cboStatus.EditValueChanged += new EventHandler(this.cboStatus_EditValueChanged);
            this.txtReasonCannot.Location = new Point(0xe8, 0xe5);
            this.txtReasonCannot.Name = "txtReasonCannot";
            this.txtReasonCannot.Size = new Size(310, 20);
            this.txtReasonCannot.TabIndex = 0x1d;
            this.txtReasonCannot.Visible = false;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.groupControl1);
            base.Name = "xucConfirmTimeKeeperAdd";
            base.Size = new Size(0x229, 0x162);
            base.Controls.SetChildIndex(this.groupControl1, 0);
            base.Controls.SetChildIndex(base.btnCancel, 0);
            base.Controls.SetChildIndex(base.btnSave, 0);
            base.Controls.SetChildIndex(base.btnSaveNew, 0);
            ((ISupportInitialize) base.Err).EndInit();
            base.imageCollection2.EndInit();
            this.txtReason.Properties.EndInit();
            this.txtDescription.Properties.EndInit();
            this.glkEmployeeCode.Properties.EndInit();
            this.gridLookUpEdit1View.EndInit();
            this.txtEmployeeName.Properties.EndInit();
            this.dtWriteDate.Properties.VistaTimeProperties.EndInit();
            this.dtWriteDate.Properties.EndInit();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.teTimeIn.Properties.EndInit();
            this.teTimeOut.Properties.EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.groupControl1.PerformLayout();
            this.glkShift.Properties.EndInit();
            this.gridView1.EndInit();
            this.dtDate.Properties.VistaTimeProperties.EndInit();
            this.dtDate.Properties.EndInit();
            this.cboStatus.Properties.EndInit();
            this.txtReasonCannot.Properties.EndInit();
            base.ResumeLayout(false);
        }

        private void LoadEmployeeInformation()
        {
            HRM_EMPLOYEE hrm_employee = new HRM_EMPLOYEE();
            hrm_employee.Get(this.m_EmployeeCode);
            this.groupControl1.Text = "Th\x00f4ng Tin X\x00e1c Nhận Giờ C\x00f4ng  - " + hrm_employee.EmployeeCode + " (" + hrm_employee.FirstName + " " + hrm_employee.LastName + ")";
            this.txtEmployeeName.Text = hrm_employee.FirstName + " " + hrm_employee.LastName;
        }

        private void RaiseSuccessEventHander(HRM_PROCESS_CONFIRMTIMEKEEPER item)
        {
            if (this.Success != null)
            {
                this.Success(this, item);
            }
        }

        public void SetCode(string EmployeeCode)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
        }

        public void SetCode(string EmployeeCode, System.DateTime FromDate, System.DateTime ToDate, string Symbol)
        {
            this.m_EmployeeCode = EmployeeCode;
            if (this.m_EmployeeCode != "")
            {
                this.glkEmployeeCode.EditValue = this.m_EmployeeCode;
                this.LoadEmployeeInformation();
            }
            this.dtWriteDate.DateTime = FromDate;
            this.dtDate.DateTime = FromDate;
            this.teTimeIn.Time = FromDate;
            this.teTimeOut.Time = ToDate;
        }

        public void SetData(HRM_PROCESS_CONFIRMTIMEKEEPER item)
        {
            SYS_LOG.Insert("Đơn X\x00e1c Nhận Giờ C\x00f4ng", "Xem", item.EmployeeCode);
            if (base.m_Status == Actions.Update)
            {
                this.glkEmployeeCode.Properties.ReadOnly = true;
                this.txtEmployeeName.Properties.ReadOnly = true;
            }
            this.m_ConfirmTimeKeeperID = item.ConfirmTimeKeeperID;
            this.glkEmployeeCode.EditValue = item.EmployeeCode;
            this.dtWriteDate.DateTime = item.WriteDate;
            this.dtDate.DateTime = item.Date;
            this.teTimeIn.Time = item.TimeIn;
            this.teTimeOut.Time = item.TimeOut;
            this.glkShift.EditValue = item.ShiftCode;
            this.txtReason.Text = item.Reason;
            this.cboStatus.SelectedIndex = item.Status;
            this.txtReasonCannot.Text = item.ReasonCannot;
            this.txtDescription.Text = item.Description;
        }

        protected override string uc_Change()
        {
            return string.Empty;
        }

        protected override string uc_Delete()
        {
            HRM_PROCESS_CONFIRMTIMEKEEPER item = new HRM_PROCESS_CONFIRMTIMEKEEPER {
                EmployeeCode = this.glkEmployeeCode.EditValue.ToString()
            };
            string str = item.Delete();
            if (str == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            return str;
        }

        protected override string uc_Save()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessConfirmTimeKeeper") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowAdd)
            {
                MyRule.Notify();
                return "";
            }
            if (this.glkEmployeeCode.EditValue == null)
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn nh\x00e2n vi\x00ean để lưu dữ liệu!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            if (this.glkShift.EditValue == null)
            {
                XtraMessageBox.Show("Vui l\x00f2ng chọn ca để x\x00e1c nhận!", "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK);
                return "";
            }
            SYS_LOG.Insert("Đơn X\x00e1c Nhận Giờ C\x00f4ng", "Th\x00eam", this.glkEmployeeCode.EditValue.ToString());
            Cursor.Current = Cursors.WaitCursor;
            this.m_ConfirmTimeKeeperID = Guid.NewGuid();
            HRM_PROCESS_CONFIRMTIMEKEEPER item = new HRM_PROCESS_CONFIRMTIMEKEEPER();
            item = this.InitClass();
            if (item == null)
            {
                return "FALSE";
            }
            base.SetWaitDialogCaption("Đang lưu dữ liệu...");
            string text = item.Insert();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            Cursor.Current = Cursors.Default;
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        protected override string uc_Update()
        {
            if (MyRule.Get(MyLogin.RoleId, "bbiProcessConfirmTimeKeeper") != "OK")
            {
                return "";
            }
            if (!MyRule.AllowEdit)
            {
                MyRule.Notify();
                return "";
            }
            SYS_LOG.Insert("Đơn X\x00e1c Nhận Giờ C\x00f4ng", "Cập Nhật", this.glkEmployeeCode.EditValue.ToString());
            base.SetWaitDialogCaption("Đang cập nhật dữ liệu...");
            HRM_PROCESS_CONFIRMTIMEKEEPER item = new HRM_PROCESS_CONFIRMTIMEKEEPER();
            item = this.InitClass();
            string text = item.Update();
            if (text == "OK")
            {
                this.RaiseSuccessEventHander(item);
            }
            if (text != "OK")
            {
                XtraMessageBox.Show(text, "Cảnh B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            this.DoHide();
            return text;
        }

        private void xucPetitionAdd_Load(object sender, EventArgs e)
        {
        }

        public delegate void SuccessEventHander(object sender, HRM_PROCESS_CONFIRMTIMEKEEPER item);
    }
}

